翻訳と辞書
Words near each other
・ "O" Is for Outlaw
・ "O"-Jung.Ban.Hap.
・ "Ode-to-Napoleon" hexachord
・ "Oh Yeah!" Live
・ "Our Contemporary" regional art exhibition (Leningrad, 1975)
・ "P" Is for Peril
・ "Pimpernel" Smith
・ "Polish death camp" controversy
・ "Pro knigi" ("About books")
・ "Prosopa" Greek Television Awards
・ "Pussy Cats" Starring the Walkmen
・ "Q" Is for Quarry
・ "R" Is for Ricochet
・ "R" The King (2016 film)
・ "Rags" Ragland
・ ! (album)
・ ! (disambiguation)
・ !!
・ !!!
・ !!! (album)
・ !!Destroy-Oh-Boy!!
・ !Action Pact!
・ !Arriba! La Pachanga
・ !Hero
・ !Hero (album)
・ !Kung language
・ !Oka Tokat
・ !PAUS3
・ !T.O.O.H.!
・ !Women Art Revolution


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Short-circuiting operator : ウィキペディア英語版
Short-circuit evaluation

Short-circuit evaluation, minimal evaluation, or McCarthy evaluation denotes the semantics of some Boolean operators in some programming languages in which the second argument is executed or evaluated only if the first argument does not suffice to determine the value of the expression: when the first argument of the AND function evaluates to false, the overall value must be false; and when the first argument of the OR function evaluates to true, the overall value must be true. In some programming languages (Lisp), the usual Boolean operators are short-circuit. In others (Java, Ada), both short-circuit and standard Boolean operators are available. For some Boolean operations, like XOR, it is not possible to short-circuit, because both operands are always required to determine the result.
The short-circuit expression ''x'' Sand ''y'' (using Sand to denote the short-circuit variety) is equivalent to the conditional expression if ''x'' then ''y'' else false; the expression ''x'' Sor ''y'' is equivalent to if ''x'' then true else ''y''.
Short-circuit operators are, in effect, control structures rather than simple arithmetic operators, as they are not strict. In imperative language terms (notably C and C++), where side effects are important, short-circuit operators introduce a sequence point – they completely evaluate the first argument, including any side effects, before (optionally) processing the second argument. ALGOL 68 used "proceduring" to achieve ''user defined'' short-circuit operators & procedures.
In loosely typed languages that have more than the two truth-values True and False, short-circuit operators may return the last evaluated subexpression, so that ''x'' Sor ''y'' and ''x'' Sand ''y'' are actually equivalent to if ''x'' then ''x'' else ''y'' and if ''x'' then ''y'' else ''x'' respectively (without actually evaluating ''x'' twice). This is called "Last value" in the table below.
In languages that use lazy evaluation by default (like Haskell), all functions are effectively "short-circuit", and special short-circuit operators are unnecessary.
==Support in common programming languages==

1 ABAP does not actually have a distinct boolean type.

2 When overloaded, the operators && and || are eager and can return any type.

3 Fortran operators are neither short-circuit nor eager: the language specification allows the compiler to select the method for optimization.

4 ISO Pascal allows but does not require short-circuiting.

5 ISO-10206 Extended Pascal supports and_then and or_else.
6 Smalltalk uses short-circuit semantics as long as the argument to and: is a block (e.g. false and: (show: 'Wont see me' )).
7 BASIC languages that supported CASE statements did so by using the conditional evaluation system, rather than as jump tables limited to fixed labels.
8 This only applies to runtime-evaluated expressions, static if and static assert. Expressions in static initializers or manifest constants use eager evaluation.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Short-circuit evaluation」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.